package org.example.application.context;

import java.io.Closeable;
import java.io.IOException;

public class RequestContext implements Closeable {
    private static final ThreadLocal<RequestContext> CONTEXT = new ThreadLocal<>();

    public static RequestContext getInstance() {
        return CONTEXT.get();
    }

    private String tenantId;

    public RequestContext() {
        CONTEXT.set(this);
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    @Override
    public void close() throws IOException {
        CONTEXT.remove();
    }
}
